#include <irrlicht.h>

#include "Client.h"
#include "Server.h"


void handleClient(Client*);
void handleServer(Server*);

int main(int argc, char** argv) {
	if(argc < 2) {
		printf("Program must be run with argument \"-C\" or \"-S\" for Client or Server. Please execute with proper arguments.\n");
		exit(0);
	}

    NetworkNode* netNode;    
    if(!strcmp(argv[1],"-S")) {
		printf("Server Mode selected.\n");
    	netNode = new Server;
    	handleServer(dynamic_cast<Server*>(netNode));
    }
    else if(!strcmp(argv[1],"-C")) {
		printf("Client Mode selected.\n");
    	netNode = new Client;
//    	dynamic_cast<Client*>(netNode)->setTargetAddress();
    	handleClient(dynamic_cast<Client*>(netNode));
    }
    else {
    	printf("Not a proper first argument. Please use either -S or -C to start a Server or Client.\n");
    	exit(0);
    }
    
    delete netNode;
    
    return 0;
}

void handleServer(Server* serv) {
	serv->execute();
}

void handleClient(Client* client) {
	client->execute();
}